__________________________________________________________________________________________________
class Solution {
public:
    int numberOfDays(int Y, int M) {
        if (M == 1 || M == 3 || M == 5 || M == 7 || M == 8 || M == 10 || M == 12) {
            return 31;
        }
        if (M == 4 || M == 6 || M == 9 || M == 11) {
            return 30;
        }
        if (Y % 400 == 0) {
            return 29;
        }
        if (Y % 100 == 0) {
            return 28;
        }
        if (Y % 4 == 0) {
            return 29;
        }
        return 28;
    }
};
__________________________________________________________________________________________________
int days[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

bool isleap(int Y)
{
    return Y%400 == 0 || Y%4 == 0 && Y%100 != 0;
}

class Solution {
public:
    int numberOfDays(int Y, int M) {
        if (isleap(Y) && M == 2)
            return 29;
        else
            return days[M];
    }
};

__________________________________________________________________________________________________
